<template>
	<view class='center'>
		<view>
			<u-form :model="form" ref="uForm">
				<u-form-item label="标题"><u-input v-model="form.title" placeholder='请输入标题' /></u-form-item>
				<u-form-item label="分类"><u-input v-model="classify" placeholder='请选择分类' type="select" @click="show = true" />
				<u-action-sheet :list="actionSheetList" v-model="show" @click="actionSheetCallback"></u-action-sheet></u-form-item>
				<u-form-item label="价钱"><u-input v-model="form.total" placeholder='金额' /></u-form-item>
				<u-form-item label="地址"><u-input v-model="form.adress" placeholder='请填写地址' /></u-form-item>
				<u-form-item label="微信"><u-input v-model="form.weixin"  /></u-form-item>
				<u-form-item label="简介" ><u-input v-model="form.content" type="textarea"/></u-form-item>
				
				
			</u-form>
		</view>
		<view class="button">
			<u-button @click="sumbit">发布求购</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				show: false,
				type:"select",
				classify:'',
				form:{
					title:'',
					category_id:'',
					adress:'',
					weixin:'',
					content:'',
					total:''
					
				},
				actionSheetList: [
									{
										value:'0',
										text: '数码产品'
									},
									{
										value:'1',
										text: '家用电器'
									},
									{
										value:'2',
										text: '服装配饰'
									},
									{
										value:'3',
										text: '家居家装'
									},{
										value:'4',
										text: '学习用品',
									},
									{   value:'5',
										text: '运动健身'
									},
									{	
										value:'6',
										text: '美妆个护'
									},
									{	value:'7',
										text: '办公用品'
									},
									{	value:'8',
										text:'母婴用品'
									},
									{	value:'9',
										text: '其他'
									}
								],
			}
		},
		methods:{
			sumbit(){
				const db = uniCloud.database();
				 db.collection("buy1").add(this.form).then(res=>{
					 console.log(res)
				 	uni.showToast({
				 		title:"发布成功"
				 	})
				  })
			},
			actionSheetCallback(index) {
							this.classify = this.actionSheetList[index].text;
							this.form.category_id=this.actionSheetList[index].value;
							console.log(this.classify)
						}
		}
		
	}
</script>

<style>
</style>
